import request from '@/utils/request'

export function listDatasource(query) {
  return request({
    url: '/datax/datasource/list',
    method: 'get',
    params: query
  })
}

export function addDatasource(data) {
  return request({
    url: '/datax/datasource',
    method: 'post',
    data: data
  })
}

export function updateDatasource(data) {
  return request({
    url: '/datax/datasource',
    method: 'put',
    data: data
  })
}

export function deleteDatasource(id) {
  return request({
    url: '/datax/datasource/' + id,
    method: 'delete'
  })
}

export function testDatasource(data) {
  return request({
    url: '/datax/datasource/test',
    method: 'post',
    data: data
  })
}

export function getTables(sid) {
  return request({
    url: '/datax/datasource/table/' + sid,
    method: 'get'
  })
}

export function getColumns(id, table) {
  return request({
    url: '/datax/datasource/table/column',
    method: 'get',
    params: {
      sid: id,
      table: table
    }
  })
}
